#!/bin/bash

# 同步各个主机的配置文件。如：/etc/hosts
sync_host_confs()
{
  echo_start "$1  ... ..."
  confirm_operate "Sync etc hosts file"
  if [ $? -eq 0 ]; then
    # 把本机的hosts文件同步给所有主机
    local value_arr=($HYREN_ALLHOSTS)
    for i in ${value_arr[@]}; do
      # 如果本机在ALLHOSTS中，则跳过
      if [ "${i}" == "$HYRENSERV_HOSTNAME" ]; then echo_warn "skip ${i}"; continue; fi
      echo_doing "sync to [${i}] ... ..."
      scp /etc/hosts root@${i}:/etc/hosts >> $SETUP_LOGFILE
      echo_done
    done
    echo_success "Sync etc hosts file done."

    echo_passed "$1 done."
  else
    echo_passed "$1 SKIP"
  fi
}